package com.jhz.speedy.ui.main;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.jhz.speedy.R;
import com.jhz.speedy.common.base.IBaseActivity;
import com.jhz.speedy.ui.login.LoginActivity;


/**
 * 闪屏
 */
public class SplashActivity extends IBaseActivity{
    private final int GO = 0;   // 跳转

    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what){
                case GO:
                    if(SplashActivity.this.isFinishing())
                        return;

                    // 跳登录页
                    Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
                    startActivity(intent);
                    finish();
                    break;
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        // 1秒后跳登录页面
        handler.sendEmptyMessageDelayed(GO, 1000);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        handler = null;
    }
}
